import { Axios } from '@/axios/axiosPlugin';
import {baseURL} from '@/config'
import router from "@/router";

function reLogin(callback = function(){}){
    Axios({
        method: 'post',
        url: baseURL + '/relogin',
        headers: {
            'Authorization': localStorage.getItem("token")
        }
    }).then(res=>{
        sessionStorage.setItem('username',res.data.data.username)
        callback();
    }).catch(error=>{
        localStorage.removeItem('token');
        router.push('/login')
    })
    callback();
}

export default reLogin;